<template>
    <div class="auto-distribute" :style="checkStatus==='0'?'-webkit-box-shadow: 0 0 5px rgba(255, 165, 0, 1)':''" :title="checkStatus==='1'?'打开自动分配':'关闭自动分配'" @click="openAuto" v-hasPermi="['ny-iqc:workLoad:getCheckStatus']">
        <img src="@/assets/images/auto-distribute.png" v-if="checkStatus==='1'" alt="" style="height: 40px;width: 40px;" />
        <img src="@/assets/images/auto-reject.png" alt="" v-if="checkStatus==='0'" style="height: 40px;width: 40px;" />

    </div>
</template>

<script>
import { updateCheckStatus, getCheckStatus } from '@/api/auto/auto'
export default {
    name: 'DialogTit',
    data() {
        return {
            isCollapse: false,
            checkStatus: '1',
        }
    },
    mounted() {
        getCheckStatus().then((res) => {
            if (
                res.data?.checkStatus === '' ||
                res.data?.checkStatus === undefined ||
                res.data?.checkStatus === null
            ) {
                this.checkStatus = '1'
            } else {
                this.checkStatus = res.data?.checkStatus
            }
        })
    },
    methods: {
        openAuto() {
            this.checkStatus = this.checkStatus === '1' ? '0' : '1'
            updateCheckStatus({ checkStatus: this.checkStatus }).then((res) => {
                this.$message.success(
                    this.checkStatus === '0'
                        ? '自动分配模式打开'
                        : '自动分配模式关闭'
                )
            })
        },
    },
}
</script>

<style scoped>
.auto-distribute {
    cursor: pointer;
    -webkit-box-shadow: 0 0 5px rgba(0, 113, 241, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    width: 68px;
    height: 68px;
    border-radius: 100%;
    position: fixed;
    right: 20px;
    bottom: 30px;
    z-index: 100;
}
.auto-close {
    -webkit-box-shadow: 0 0 5px rgba(255, 165, 0, 1);
}
</style>
